#!/usr/bin/env bash
set -e
mkdir -p /opt/tmp


wget https://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.4.6/sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
tar zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz

mv sqoop-1.4.6.bin__hadoop-2.0.4-alpha/ /opt/sqoop
mv sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz /opt/tmp/


echo -e "export SQOOP_HOME=/opt/sqoop/\nexport PATH=\$SQOOP_HOME/bin:\$PATH">>/etc/profile

wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar
mv mysql-connector-java-5.1.30.jar /opt/sqoop/lib/

mv /opt/sqoop/conf/sqoop-env-template.sh /opt/sqoop/conf/sqoop-env.sh

env=/opt/sqoop/conf/sqoop-env.sh



echo -e "
export HADOOP_COMMON_HOME=/opt/hadoop
export HADOOP_MAPRED_HOME=/opt/hadoop
export HBASE_HOME=/opt/hbase
export ZOOCFGDIR=/opt/zookeeper
">>$env

#export HADOOP_COMMON_HOME=

#sqoop list-databases --connect jdbc:mysql://123.206.210.251:3307/superviory_real_test --username 'supervisory' --password 'lx@v5.com'
#sqoop  import --connect jdbc:mysql://123.206.210.251:3307/superviory_real_test --username 'supervisory' --password 'lx@v5.com' --table t_user --hbase-table user --hbase-create-table --hbase-row-key mark_id --column-family url
#sqoop  import --connect jdbc:mysql://123.206.210.251:3307/superviory_real_test --username 'supervisory' --password 'lx@v5.com' --table t_user --hbase-table user --hbase-row-key user_id --column-family region